home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir42
/
c7105.zip
/
CPD21.TPX
< prev
next >
Wrap
Text File
|
1994-03-02
|
66KB
|
1,552 lines
#!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
#!│ CPD21.TPX │Version: 3007.105│
#!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
#!│Structure Type Description │
#!│──────────────────── ───────── ─────────────────────────────────────────│
#!│Table21 PROCEDURE Version 2.1-Style Table Procedure │
#!│Form21 PROCEDURE Version 2.1-Style Form Procedure │
#!│MemForm21 PROCEDURE Version 2.1-Style MemForm Procedure │
#!│Menu21 PROCEDURE Version 2.1-Style Menu Procedure │
#!│BeginRepeat GROUP │
#!│RepeatErrorCheck GROUP │
#!│Form21KeyHandling GROUP │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!│3007.103 Repaired Form21 Procedure │
#!│3007.105 Repaired Form21 Procedure │
#!│ Repaired MemForm21 Procedure │
#!│ Repaired Table21 Procedure │
#!│ Repaired Menu21 Procedure │
#!│ Added Form21Keyhandling GROUP │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#PROCEDURE(Table21,'Version 2.1-Style Table Procedure'),SCREEN,PULLDOWN
#!
#!┌──────────────────────────┤Procedure Template├──────────┬─────────────────┐
#!│ Table21 │Version: 3007.105│
#!├──────────────────────────────┤Description├─────────────┴─────────────────┤
#!│ The Table21 Template generates a Clarion Professional Developer 2.1 type │
#!│ Table procedure. This procedure uses the REPEAT library procedures │
#!│ built in to %clapfx%REPEA.LIB, whose source code is in REPEAT.CLA │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!│3007.105 Completed support for PullDowns │
#!│ Repaired BREAK in main loop, replacing it with DO │
#!│ ProcedureReturn │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#PROMPT('Range &Limit Field',COMPONENT),%KeyRangeField
#PROMPT('Range &Value Field',FIELD),%RangeValue
#PROMPT('Record Filter',@S180),%RecordFilter
#PROMPT('Locator Field',COMPONENT),%Locator
#PROMPT('Incremental Locator',CHECK),%IncrementalLocator
#PROMPT('Upd&ate Procedure',PROCEDURE),%UpdateProc
#PROMPT('Update Call in Embed',CHECK),%EmbeddedUpdate
#PROMPT('Enable Hot Records',CHECK),%HotBar
#INSERT(%StandardHeader)
#MAP('REPEAT.INC')
#PROJECT('%clapfx%REPEA.LIB')
#PROTOTYPE('(<BYTE>)')
%Procedure PROCEDURE(Mode)
#INSERT(%SetBrowseSymbols)
#INSERT(%RepeatErrorCheck)
#FIX(%ScreenField,'?Exit')
#IF(%ScreenField)
#SET(%ExitExists,'1')
#ELSE
#SET(%ExitExists,%Null)
#ENDIF
#SET(%FirstField,%Null)
#FOR(%ScreenField)
#IF(%ScreenFieldSkip)
#SET(%FirstField,%ScreenField)
#BREAK
#ENDIF
#ENDFOR
#IF(%FirstField = %Null AND %ExitExists = %NULL)
#SET(%ErrorMessage,'Table21 Must Have Exit Button If All Fields Are SKIP')
#ERROR(%ErrorMessage)
#ENDIF
#!
#IF(%KeyRangeField)
#FIX(%Key,%PrimaryKey)
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
SAV::%KeyField Like(%KeyField)
#ENDIF
#IF(UPPER(%KeyField) = UPPER(%KeyRangeField))
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
ButtonIsDisabled BYTE !Flag to allow button enable
RptInitialized BYTE(0)
Ndx BYTE
MaxRows BYTE
#INSERT(%FileControl)
%LocalData
%ScreenStructure
#IF(%PullDown)
%PulldownStructure
SAV::PullDownOpened BYTE(0)
#ENDIF
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#INSERT(%FileControl)
#FIX(%File,%Primary)
OPEN(Screen) !Open the screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
#INSERT(%SaveRangeFields)
#IF(%Pulldown) #!If a pulldown exists
OPEN(%Pulldown) #<!Open the pulldown menu
SAV::PullDownOpened = True
#EMBED('Setup Pulldown') #! Embedded Source Code
#ENDIF
#INSERT(%BeginRepeat)
RptInitialized = TRUE
Ndx = 1 !Set first point bar position
#FIX(%ScreenField,'?Select')
#IF(%ScreenField)
#SET(%SelectExists,'1')
IF Mode <> SelectRecord #<!Is This Not In Select Mode?
DISABLE(?Select) ! Dim the select button
END !End IF
#ELSE
#SET(%SelectExists,%Null)
#ENDIF
LOOP !Process table requests
ALERT(EscKey) !Alert the EscKey
ALERT(CtrlEsc) !Alert the CtrlEsc
CASE RepeatAction(%Primary,%PrimaryKey,Ndx)#<!Scroll the file
OF ProcessField !Process a field
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'POINT')
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDIF
#ENDFOR
#EMBED('End of General Formulas')
CASE KEYCODE() !User defined hotkey check
#FOR(%HotKey)
OF %HotKey #<!User defined HotKey
%HotKeyProc #<!HotKey Procedure
#ENDFOR
OF EscKey !On EscKey
IF FIELD() = %FirstField #<!If first field
#IF(%ExitExists = %Null)
GET(%Primary,0)
DO ProcedureReturn
#ELSE
SELECT(?Exit)
PRESS(EnterKey)
CYCLE
#ENDIF
#IF(%ExitExists = %Null)
ELSE
SELECT(?-1)
CYCLE
END
#ELSE
ELSIF FIELD() <> ?Exit
SELECT(?-1)
CYCLE
END
#ENDIF
OF CtrlEsc !On exit
#IF(%ExitExists = %Null)
GET(%Primary,0)
DO ProcedureReturn
#ELSE
IF FIELD() <> ?Exit
SELECT(?Exit)
PRESS(EnterKey)
CYCLE
END
#ENDIF
END !End CASE
IF SELECTED() <> FIELD() ! If a new field is selected
CASE SELECTED() ! Jump to setup routine
#IF(%KeyRangeField)
OF ?Point ! Save range on point bar
#INSERT(%SaveRangeFields)
#ENDIF
#INSERT(%ScreenSetupRoutines)
END ! End CASE SELECTED()
END ! End IF
CASE FIELD() !Jump to edit routine
#FOR(%ScreenField)
#IF(%ScreenField = '?Insert')
#IF((%UpdateProc OR %EmbeddedUpdate))
OF ?Insert !Process the Insert Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Insert button Edit Routine
#ENDIF
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Set action to insert
DO UpdateProcedure ! Call the update procedure
SELECT(?Point) ! Reselect the point field
#ENDIF
#ELSIF(%ScreenField = '?Change')
#IF((%UpdateProc OR %EmbeddedUpdate))
OF ?Change !Process the Change Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Change button Edit Routine
#ENDIF
SETKEYCODE(EnterKey) ! Set action to Change
DO UpdateProcedure ! Call the update procedure
SELECT(?Point) ! Reselect the point field
#ENDIF
#ELSIF(%ScreenField = '?Select')
#IF((%UpdateProc OR %EmbeddedUpdate))
OF ?Select !Process the Change Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Change button Edit Routine
#ENDIF
DO ProcedureReturn
#ENDIF
#ELSIF(%ScreenField = '?Delete')
#IF((%UpdateProc OR %EmbeddedUpdate))
OF ?Delete !Process the delete button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Delete button edit routine
#ENDIF
SETKEYCODE(DelKey) ! Set action to delete
DO UpdateProcedure ! Call the update procedure
SELECT(?Point) ! Reselect the point field
#ENDIF
#ELSIF(%ScreenField = '?Point')
OF ?Point !Process the list field
#IF((%UpdateProc OR %EmbeddedUpdate))
CASE KEYCODE() ! Jump to keycode routine
#IF(%KeyboardInsert)
OF InsKey ! For the insert key
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
DO UpdateProcedure ! Call the update procedure
#ENDIF
#IF(%KeyboardDelete)
OF DelKey ! For the delete key
DO UpdateProcedure ! Call the update procedure
#ENDIF
#IF(%KeyboardChange AND %KeyboardSelect)
OF EnterKey ! Or the enter key
OROF MouseLeft2 ! Or a double mouse click
IF Mode = SelectRecord ! When selection mode
DO ProcedureReturn ! Return to caller
ELSE ! Else
DO UpdateProcedure ! Call update procedure
END ! End IF
OF CtrlEnter
DO UpdateProcedure
#ELSIF(%KeyboardChange)
OF EnterKey ! Or the enter key
OROF MouseLeft2 ! Or a double mouse click
DO UpdateProcedure ! Call update procedure
#ELSIF(%KeyboardSelect)
OF EnterKey ! Or the enter key
OROF MouseLeft2 ! Or a double mouse click
IF Mode = SelectRecord ! When selection mode
DO ProcedureReturn ! Return to caller
END
#ENDIF
END ! End CASE
#ELSE
IF KEYCODE() = EnterKey OR | ! Or the enter key
KEYCODE() = MouseLeft2 ! Or a double mouse click
IF Mode = SelectRecord ! When selection mode
DO ProcedureReturn ! Return To Caller
END ! End IF
END ! End IF
#ENDIF
#ELSIF(%ScreenField = '?Exit')
OF ?Exit !Process the Exit button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Exit button Edit Routine
#ENDIF
GET(%Primary,0) ! Dereference For Select
DO ProcedureReturn ! Return to caller
#ELSE
#INSERT(%ScreenEditRoutines) #<! Completed %ScreenField
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD()
OF NoRecords !No records to browse
#INSERT(%ClearFileFields)
#INSERT(%RestoreRangeFields)
DISPLAY !Redisplay the screen
#IF(%ChangeExists)
DISABLE(?Change) ! Disable the change button
#ENDIF
#IF(%DeleteExists)
DISABLE(?Delete) ! Disable the delete button
#ENDIF
ButtonIsDisabled = TRUE ! Set to button is disabled
IF RECORDS(%Primary) #<! If file is not empty
IF ?Point <> %FirstEntryField #<! And point is not first
SELECT(%FirstEntryField) #<! Select the first field
ELSE ! Else
#IF((%UpdateProc OR %EmbeddedUpdate))
#IF(%InsertExists)
SELECT(?Insert) ! Select the Insert Button
#ELSE
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
DO UpdateProcedure ! Call the update procedure
IF POSITION(%PrimaryKey) = '' #<! If record not added
DO ProcedureReturn ! Return to caller
ELSE ! Else record was added
#IF(%ChangeExists)
ENABLE(?Change) ! Enable change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Enable delete button
#ENDIF
ButtonIsDisabled = FALSE ! Set to button enabled
END ! End IF
#ENDIF
#ELSE
DO ProcedureReturn ! Return to caller
#ENDIF
END ! End IF
ELSE ! Else if file is empty
#IF((%UpdateProc OR %EmbeddedUpdate))
#INSERT(%RestoreRangeFields)
SETKEYCODE(InsKey) ! Ask for a new record
DO UpdateProcedure ! Call the update procedure
IF POSITION(%PrimaryKey) = '' #<! If record not added
DO ProcedureReturn ! Return to caller
ELSE ! Else record was added
#IF(%ChangeExists)
ENABLE(?Change) ! Enable change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Enable delete button
#ENDIF
ButtonIsDisabled = FALSE ! Set to button enabled
END ! End IF
#ELSE
DO ProcedureReturn ! Return to caller
#ENDIF
END ! End IF
OF FilterRecord !Should we add this record
IF ButtonIsDisabled ! If button is disabled
#IF(%ChangeExists)
ENABLE(?Change) ! Enable change button
#ENDIF
#IF(%DeleteExists)
ENABLE(?Delete) ! Enable delete button
#ENDIF
ButtonIsDisabled = FALSE ! Set to button enabled
END ! End IF
#IF(%KeyRangeField) #!If using range limits
#IF(%RangeValue) #! If using range value field
#IF(%KeyNoCase) #! Key is not case sensitive
IF (UPPER(%KeyRangeField) <> UPPER(%RangeValue)) #<! If range field has changed
#ELSE
IF (%KeyRangeField <> %RangeValue) #<! If range field has changed
#ENDIF
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
#INSERT(%RestoreRangeFields)
CYCLE ! Cycle for BrowseAction
END ! End IF
#ELSE
#SET(%Found, %Null)
#FOR(%KeyField)
#IF(%Found <> 'Yes')
#IF(%KeyNoCase) #! Key is not case sensitive
IF (UPPER(%KeyField) <> UPPER(SAV::%KeyField)) #<! If range field has changed
#ELSE
IF (%KeyField <> SAV::%KeyField) #<! If range field has changed
#ENDIF
PREVIOUS(%Primary) #<! Signal browse to build
#INSERT(%ClearFileFields) #! Clear for screen fields
#INSERT(%RestoreRangeFields)
CYCLE ! Cycle for BrowseAction
END ! End IF
#ENDIF
#IF(UPPER(%KeyField) = UPPER(%KeyRangeField))
#SET(%Found, 'Yes')
#ENDIF
#ENDFOR
#ENDIF
#ENDIF
#IF(%RecordFilter)
IF ~(%RecordFilter) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'FILTER')
#IF(%FormulaType <> 'COMPUTED')
IF ~(%FormulaCondition) #<!If Filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to Top of LOOP
END !End IF
#ELSE
IF ~(%FormulaComputation) #<!If filter condition not met
GET(%Primary,0) #<! Dereference the record
CYCLE ! Return to top of LOOP
END !End IF
#ENDIF
#ENDIF
#ENDFOR
#ENDIF
#EMBED('After Filter and Range Check')
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'POINT')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('POINT Class formula')
OF ResetFirst !Set to first in a range
#IF(%KeyRangeField)
#INSERT(%ClearRecordLow)
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey) #<! SET to the closest match
#ENDIF
#EMBED('Set to First Record')
OF ResetLast !Set to last in a range
#IF(%KeyRangeField)
#INSERT(%ClearRecordHigh)
CLEAR(Pointer#,1) !
#INSERT(%RestoreRangeFields)
SET(%PrimaryKey,%PrimaryKey,Pointer#) #<! SET to the closest match
#ENDIF
#EMBED('Set to Last Record')
#IF(%HotBar)
OF ProcessSelected !Process highlighted record
#INSERT(%GetSecondaryRecords)
#FOR(%Formula)
#IF(UPPER(%FormulaClass) <> 'FILTER')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#EMBED('Process Selected Record')
DISPLAY() #<! Display the hot fields
#ENDIF
#IF(%Locator)
OF ClearRestOfKey !Clear subfields of a locator
#SET(%ClearSW,'0')
#FOR(%KeyField)
#IF(%ClearSW = '1')
CLEAR(%KeyField)
#ENDIF
#IF(%KeyField = %Locator)
#SET(%ClearSW,'1')
#ENDIF
#ENDFOR
#ENDIF
END ! End CASE
END !End LOOP
DO ProcedureReturn
#IF((%UpdateProc OR %EmbeddedUpdate))
UpdateProcedure ROUTINE
#EMBED('Prior to Update Procedure')
%UpdateProc #<!Call the update procedure
#EMBED('After Update Procedure')
#ENDIF
#!
!─────────────────────────────────────────────────────────────────────────────
ProcedureReturn ROUTINE
IF RptInitialized
EndRepeat !End the Repeat session
END
#IF(%Pulldown) #! If a Pulldown exists
IF SAV::PullDownOpened #<! IF the pulldown opened
CLOSE(%Pulldown) #<! Close the Pulldown
END #<! END (IF the pulldown...)
#ENDIF #! END (IF a PullDown...)
#INSERT(%FileControl)
DO EndOfProcedureEmbed
RETURN
!─────────────────────────────────────────────────────────────────────────────
EndOfProcedureEmbed ROUTINE
#EMBED('End of Procedure')
#EMBED('Custom Routines')
#PROCEDURE(Form21,'Version 2.1-Style Form Procedure'),SCREEN,PULLDOWN
#!
#!┌──────────────────────────┤Procedure Template├──────────┬─────────────────┐
#!│ Form21 │Version: 3007.105│
#!├──────────────────────────────┤Description├─────────────┴─────────────────┤
#!│ The Form21 Template generates a Clarion Professional Developer 2.1 type │
#!│ Form procedure. │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!│3007.103 Added RI Initialization Code │
#!│ Added RI Initialization Code │
#!│3007.105 Completed support for PullDowns │
#!│ Removed duplicate AbortTransaction declaration │
#!│ Repaired Escape Key Handling (Extra END) │
#!│ Increased size of Message Prompts to @S30. │
#!│ Moved call to ShowWarning in I/O code to WARNINGS.TPX │
#!│ Removed a BREAK in main processing loop and replaced it with │
#!│ DO ProcedureReturn │
#!│ Moved call to FREE(RecordQueue) to ProcedureReturn ROUTINE │
#!│ Moved CASE KEYCODE() handing to Form21KeyHandling GROUP │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#PROTOTYPE('')
#PROMPT('Insert message',@S30),%InsertMsg
#PROMPT('Chan&ge message',@S30),%ChangeMsg
#PROMPT('De&lete message',@S30),%DeleteMsg
#PROMPT('Action after ADD',OPTION),%AddAction
#PROMPT('Return to caller ',RADIO)
#PROMPT('Retain Record ',RADIO)
#PROMPT('Clear Record ',RADIO)
#PROMPT('Copy field hot&key:',KEYCODE),%CopyKey
#PROMPT('Next Procedure ',PROCEDURE),%NextProcedure
#INSERT(%StandardHeader)
#INSERT(%InitFormSymbols)
#IF(%Primary = %NULL)
#SET(%ErrorMessage,(' WARNING during Code Generation in Procedure: '& %Procedure ))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage,( ' No File Defined In File Schematic For FORM Template '))
#ERROR(%ErrorMessage)
#ENDIF
%Procedure PROCEDURE
%LocalData
SelectedField SHORT !Process selected Field
#INSERT(%FileControl) #!Primary or Secondary Opened
NoMoreFields BYTE(0) !No more fields flag
#IF(UPPER(CLIP(%AddAction)) = 'RETAIN RECORD')
#IF(%CopyKey)
SCREEN %ScreenAttributes,ALRT(%CopyKey)
%ScreenPaintDeclarations
%ScreenStringDeclarations
%ScreenFieldDeclarations
.
#IF(NOT %SharedFiles)
SAV:SaveRecord LIKE(%FilePre:Record),PRE(SAV)
#ENDIF
#ELSE
%ScreenStructure
#IF(NOT %SharedFiles)
SAV:SaveRecord LIKE(%FilePre:Record),PRE(SAV)
#ENDIF
#ENDIF
#ELSE
%ScreenStructure
#ENDIF
#IF(%PullDown)
%PulldownStructure
SAV::PullDownOpened BYTE(0)
#ENDIF
#IF(%SharedFiles)
RecordQueue QUEUE,PRE(SAV) !Queue for concurrency checking
SaveRecord LIKE(%FilePre:Record),PRE(SAV) #<!size of primary file record
#FOR(%FileMemo)
#FIX(%Field,%FileMemo)
SAV:%FieldID STRING(SIZE(%FileMemo))
#ENDFOR
. #<!End Queue structure
#ENDIF
AbortTransaction BYTE
#IF(%RelatedChildList)
#SET(%ProcessingFile,%Primary)
#INSERT(%RelationalAccessFlds) #<!Declare link fields
RI:RestrictUpdate byte
RI:RestrictDelete byte
#IF(%PrimaryDriver = 'Paradox3')
#FIX(%File,%Primary)
UpdRelation STRING(SIZE(%FilePre:Record)) #<!Position of last related record
#ELSE
UpdRelation STRING(10) #<!Position of last related record
#ENDIF
#IF(%PrimaryDriver='Btrieve')
SAV:Position string(255)
#ENDIF
#ENDIF
#IF(%PrimaryDriver = 'Paradox3')
#FIX(%File,%Primary)
SavePointer STRING(SIZE(%FilePre:Record)) !Position of current record
AutoAddPtr STRING(SIZE(%FilePre:Record)) !Position of Autoinc record
#ELSE
SavePointer STRING(10) !Position of current record
AutoAddPtr STRING(10) !Position of Autoinc record
#ENDIF
AutoIncAdd BYTE(0) !On for Autoincrement add
#IF(UPPER(CLIP(%AddAction)) <> 'RETURN TO CALLER')
LastPosition STRING(10) !Position of last ADD
#ENDIF
#IF(UPPER(CLIP(%AddAction)) = 'RETAIN RECORD')
#IF(%CopyKey)
#INSERT(%FieldDups)
#ENDIF
#ENDIF
#IF(%PrimeKeysExist)
#INSERT(%SavePrimedFields)
#ENDIF
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#INSERT(%FileControl) #<!Ensure Primary file is OPEN
#SET(%OkExists,%Null)
#SET(%CancelExists,%Null)
#FIX(%ScreenField,'?Ok')
#IF(%ScreenField)
#SET(%OkExists,'TRUE')
#ENDIF
#FIX(%ScreenField,'?Cancel')
#IF(%ScreenField)
#SET(%CancelExists,'TRUE')
#ENDIF
#SET(%FirstField,%Null)
#FOR(%ScreenField)
#IF(NOT %ScreenFieldSkip AND %FirstField= %Null)
#SET(%FirstField,%ScreenField)
#ENDIF
#IF(NOT %ScreenFieldSkip)
#SET(%LastField,%ScreenField)
#ENDIF
#ENDFOR
#IF(%FirstField = %Null AND %CancelExists = %NULL)
#SET(%ErrorMessage,'Form21 Must Have Cancel Button If All Fields Are SKIP')
#ERROR(%ErrorMessage)
#ENDIF
#SET(%TableForm,'TRUE')
CASE KEYCODE() !What Key was pressed?
OF InsKey !Insert a new record
Action = AddRecord !Set action code 1 (ADD)
#INSERT(%InsertMessage) #<!Message for ADD RECORD
#IF(%AutoInc)
DO AutoNumber !Set autonumber key field(s)
#ELSE
#INSERT(%ClearValues)
#ENDIF
#EMBED('On Add After Record Buffer Is Cleared')
#IF(%InitRoutine) #<!Field(s) initial value
DO InitializeFields !Initial values from dictionary
#ENDIF
OF EnterKey !Process a CHANGE request
OROF MouseLeft2 !on EnterKey or double mouse
Action = ChangeRecord !Set action code 2 (CHANGE)
#INSERT(%ChangeMessage) #<!Message for CHANGE RECORD
#IF(%SharedFiles)
#INSERT(%SetupConcurrency) #<!Setup multi-user Concurrency
#ENDIF
#IF(%CascadeUpdate OR %ClearOnUpdate OR %RestrictUpdate)
DO RelationAccessSave !Save LINKS for relational update
#SET(%RelUpdateRoutine,'TRUE')
#ENDIF
OF DelKey !Process a DELETE request
Action = DeleteRecord !Set action code 3 (DELETE)
#INSERT(%DeleteMessage) #<!Message for DELETE RECORD
SavePointer = POSITION(%Primary) #<!Position in PRIMARY file
#IF(%CascadeDelete OR %ClearOnDelete OR %RestrictDelete)
DO RelationAccessSave !Save LINKS for relational update
#SET(%RelDeleteRoutine,'TRUE')
#ENDIF
END !End CASE Keycode
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'SETUP')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#IF(%SecondaryExist) #<!IF schema has a Secondary
DO SecondaryLookups !Read any lookup fields
#ENDIF
#IF(%PullDownStructure)
OPEN(%PullDown)
SAV::PullDownOpened = True
#EMBED('Setup Pulldown') #! Embedded Source Code
#ENDIF
OPEN(Screen) !Open the FORM screen
IF Action = DeleteRecord !IF request for DELETE
DISABLE(1,FIELDS()) !Disable all screen fields
#IF(%OkExists)
ENABLE(?OK) !Enable the OK and the
#ENDIF
#IF(%CancelExists)
ENABLE(?Cancel) !Cancel buttons
#ENDIF
END !End IF request for delete
#EMBED('Setup Screen')
DISPLAY !Display screen fields
LOOP !Begin Main process loop
#IF(%SecondaryExist) #<!IF File schema has Secondary
#INSERT(%SecondaryChanged)
#ENDIF
#IF(%LoopFormulasExist) #<!Are there Formula fields?
#SET(%GenerateFormulasOn,'TRUE')
DO FormulaFields !Calculate Formula fields
#ENDIF
#EMBED('Computed Fields')
DISPLAY
SelectedField = SELECTED()
IF FIELD() = %LastField AND SelectedField = %LastField |
AND Action <> DeleteRecord
SelectedField = NoMoreFields !Enter On Last Field
#IF(~%OkExists)
ELSIF Action = DeleteRecord
Abort# = False
LOOP
ASK
CASE KEYCODE()
OF EnterKey
OROF CtrlEnter
SelectedField = NoMoreFields !Accepted Delete
BREAK
OF EscKey
OROF CtrlEsc
Abort# = True
BREAK
ELSE
CYCLE
END
END
IF Abort#
DO ProcedureReturn
END
#ENDIF
END
CASE SelectedField !Process selected Field
#INSERT(%ScreenSetupRoutines)
OF NoMoreFields !User pressed Enter or OK
CASE Action !Process requested Action
OF AddRecord !Action = 1 (ADD)
ADD(%Primary) #<!Add Record to Primary file
OF ChangeRecord !Action = 2 (Change)
#IF(%SharedFiles) #!If making a network app
#IF(%AutoInc)
IF AutoIncAdd #<!Was this an Autonumber?
#IF(UPPER(CLIP(%AddAction)) <> 'RETURN TO CALLER')
LastPosition = POSITION(%Primary) #<!Save last record position
#ENDIF
PUT(%Primary) #<!Write the Record
ELSE #<!not AutoincAdd
#ENDIF
DO ConcurrentWrite !Concurrent update ROUTINE
IF AbortTransaction !AbortWrite is on
#IF(%CancelExists)
SELECT(?Cancel) !Place cursor on cancel
CYCLE !Restart Loop
#ELSE
PRESS(EscKey)
SELECT(%FirstField)
CYCLE !Restart Loop
#ENDIF
END
#ELSE
#IF(UPPER(CLIP(%AddAction)) <> 'RETURN TO CALLER')
LastPosition = POSITION(%Primary) #<!Save last record position
#ENDIF
#ENDIF
#IF(%UpdateChildList)
DO ConstrainedUpdate #<!Write the Record
IF AbortTransaction
#IF(%CancelExists)
SELECT(?Cancel) !Place cursor on cancel
CYCLE !Restart Loop
#ELSE
PRESS(EscKey)
SELECT(%FirstField)
CYCLE !Restart Loop
#ENDIF
END
#ELSE
PUT(%Primary)
#ENDIF
#IF((%SharedFiles AND %AutoInc))
END #<!IF AutoIncAdd
#ENDIF
OF DeleteRecord !Action = 3 (Delete)
#IF(%SharedFiles)
DO ConcurrentDelete
IF AbortTransaction
#IF(%CancelExists)
SELECT(?Cancel) !Place cursor on cancel
CYCLE !Restart Loop
#ELSE
PRESS(EscKey)
SELECT(%FirstField)
CYCLE !Restart Loop
#ENDIF
END
#ENDIF
#IF(%DeleteChildList)
DO ConstrainedDelete #<!Write the Record
IF AbortTransaction
#IF(%CancelExists)
SELECT(?Cancel) !Place cursor on cancel
CYCLE !Restart Loop
#ELSE
PRESS(EscKey)
SELECT(%FirstField)
CYCLE !Restart Loop
#ENDIF
END
#ELSE
DELETE(%Primary)
#ENDIF
END !End CASE Action
IF ERRORCODE() !Error check on File I/O
#IF(%DupKeyCheck)
#INSERT(%DupKeyCode)
#ENDIF
#INSERT(%UpdateErrorMsg)
#IF(%SharedFiles)
RELEASE(%Primary) #<!Release the held record
#ENDIF
#IF(%CancelExists)
DISABLE(1,FIELDS()) !Disable all the fields
ENABLE(?Cancel) !Enable Cancel button
SELECT(?Cancel) !and place cursor on Cancel
DISPLAY !Re-display the screen
CYCLE !Re-start main LOOP
#ELSE
PRESS(EscKey)
SELECT(%FirstField)
CYCLE !Restart Loop
#ENDIF
ELSE !Else no errorcode()
#IF(%SharedFiles)
FREE(RecordQueue) !Free memory from Queue
#ENDIF
#EMBED('Setup Next Procedure')
%NextProcedure #<!Call the Next Procedure
#EMBED('Return from Next Procedure')
#IF(UPPER(CLIP(%AddAction)) <> 'RETURN TO CALLER')
IF Action = AddRecord #<!If Action is AddRecord
LastPosition = POSITION(%Primary) #<!Save position of last ADD
END #<!End IF Action = AddRecord
#ENDIF
#IF(UPPER(CLIP(%AddAction)) = 'CLEAR RECORD')
IF (Action = AddRecord) OR (Action = ChangeRecord AND AutoIncAdd)
ERASE #<!Erase screen fields
#INSERT(%InsertMessage) #<!Message for ADD RECORD
DISPLAY !Update screen display
#FIX(%File,%Primary)
CLEAR(%FilePre:Record) #<!Clear the record buffer
#IF(%AutoInc)
DO AutoNumber !Increment autonumber key
#IF(%InitRoutine)
DO InitializeFields !Initial value from DataDictionary
#ENDIF
DISPLAY !Display screen field
#ENDIF
SELECT(1) !Place cursor on 1st field
#EMBED('After ADD on Retain and Clear record')
CYCLE !Re-start main LOOP
END !End IF (Action = ....)
#ELSIF(UPPER(CLIP(%AddAction)) = 'RETAIN RECORD')
IF (Action = AddRecord) OR (Action = ChangeRecord AND AutoIncAdd)
#IF(%CopyKey)
DO SaveScrFlds #<!Save the Screen fields
ERASE
#INSERT(%InsertMessage) #<!Message for ADD RECORD
DISPLAY !Update screen display
#FIX(%File,%Primary)
CLEAR(%FilePre:Record) #<!Clear the record buffer
#ELSE
#IF(%AutoInc)
SAV:SaveRecord = %FilePre:Record #<!Save the record buffer
#ENDIF
#ENDIF
#IF(%AutoInc)
DO AutoNumber !Increment autonumber key
%FilePre:Record = SAV:SaveRecord #<!Restore saved record
#INSERT(%RestoreAuto) #<!Restore AutoNumber(s)
DISPLAY !Display screen fields
#ENDIF
SELECT(1) !Place cursor on 1st field
#EMBED('After ADD on Retain and Clear record')
CYCLE !Re-start main LOOP
END !End IF (Action = ....)
#ENDIF #!End %AddAction code
DO ProcedureReturn !Break from main Loop
END !End IF Errorcode()
END !End CASE Selected()
ALERT(EscKey)
#IF(%CancelExists = %Null)
ALERT(CtrlEsc)
#ENDIF
#IF(%OKExists = %Null)
ALERT(CtrlEnter)
#ENDIF
ACCEPT !Enable screen entry
#IF(UPPER(CLIP(%AddAction)) = 'RETAIN RECORD')
#IF(%CopyKey)
#INSERT(%DupFldCall)
#ENDIF
#ENDIF
#INSERT(%Form21KeyHandling)
#IF(%CancelExists = %Null)
IF KEYCODE() = CtrlEsc OR (KEYCODE() = EscKey AND FIELD() = %FirstField)
#IF(%AutoInc)
IF AutoIncAdd !ADDed autoincrement record?
RESET(%Primary,AutoAddPtr) #<!Re-position record pointer
NEXT(%Primary) #<!Re-read the record we added
IF DiskError('Could not READ Record') !Check for file I/O error
DO ProcedureReturn !Return to caller
END !End IF Diskerror
DELETE(%Primary) #<!DELETE the record
IF DiskError('Record could not be Deleted')
DO ProcedureReturn !Return to caller
END !End IF Diskerror
END !End IF AutoIncAdd
#ENDIF
#IF(UPPER(CLIP(%AddAction)) <> 'RETURN TO CALLER')
IF LastPosition #<!IF a record was added
RESET(%Primary,LastPosition) #<!Position to the record
NEXT(%Primary) #<!and read it
ELSE #<!Else no LastPosition
GET(%Primary,0) #<!signal Browse to re-read
END #<!END If LastPosition
#ELSE
GET(%Primary,0) #<!signal Browse to re-read
#ENDIF
DO ProcedureReturn #<! Return to caller
END
#ENDIF
CASE FIELD() !Process fields
#FOR(%ScreenField)
#IF(%ScreenFieldUse = '?Ok')
OF ?Ok !On the OK button
#EMBED('OK Button Press')
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Field Edit procedure
#ENDIF
SELECT(1) !Start with the first field
SELECT !and cycle non-stop
CYCLE !restart main process loop
#ELSIF(%ScreenFieldUse = '?Cancel')
OF ?Cancel #<! On Cancel button
#IF(%AutoInc)
IF AutoIncAdd #<! ADDed autoincrement record?
RESET(%Primary,AutoAddPtr) #<! Re-position record pointer
NEXT(%Primary) #<! Re-read the record we added
IF DiskError('Could not READ Record') #<! Check for file I/O error
DO ProcedureReturn #<! Return to caller
END #! END (Check for file I/O...)
DELETE(%Primary) #<! DELETE the record
IF DiskError('Record could not be Deleted')#<! IF cannot delete
DO ProcedureReturn #<! Return to caller
END #<! End IF Diskerror
END #<! End IF AutoIncAdd
#ENDIF
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Field edit procedure
#ENDIF
#IF(UPPER(CLIP(%AddAction)) <> 'RETURN TO CALLER')
IF LastPosition #<!IF a record was added
RESET(%Primary,LastPosition) #<!Position to the record
NEXT(%Primary) #<!and read it
ELSE #<!Else no LastPosition
GET(%Primary,0) #<!signal Browse to re-read
END #<!END If LastPosition
#ELSE
GET(%Primary,0) #<!signal Browse to re-read
#ENDIF
DO ProcedureReturn #<! Return to caller
#ELSIF(%ScreenField = %LastField)
OF %LastField
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<!Field edit procedure
#ENDIF
CYCLE !restart main process loop
#ELSE
#INSERT(%ScreenEditRoutines) #<! Completed %ScreenField
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD
END !END MAIN PROCESS LOOP
DO ProcedureReturn
!─────────────────────────────────────────────────────────────────────────────
ProcedureReturn ROUTINE
#IF(%SharedFiles)
FREE(RecordQueue) !Free the memory Queue
#ENDIF
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'RETURN')
#INSERT(%GenerateFormula) #<!Return Class formula
#ENDIF
#ENDFOR
#IF(%Pulldown) #! If a Pulldown exists
IF SAV::PullDownOpened #<! IF the pulldown opened
CLOSE(%Pulldown) #<! Close the Pulldown
END #<! END (IF the pulldown...)
#ENDIF #! END (IF a PullDown...)
#INSERT(%FileControl)
DO EndOfProcedureEmbed
RETURN
!─────────────────────────────────────────────────────────────────────────────
EndOfProcedureEmbed ROUTINE
#EMBED('End of Procedure')
#EMBED('Custom Routines')
#INSERT(%AutoIncCode)
#INSERT(%ConcurrentWrite)
#INSERT(%ConcurrentDelete)
#INSERT(%RIUpdates)
#INSERT(%RIDeletes)
#INSERT(%InitQue)
#INSERT(%InitFields)
#INSERT(%GenFormulas)
#IF(%SecondaryExist)
#INSERT(%SecondaryLookups)
#ENDIF
#IF(UPPER(CLIP(%AddAction)) = 'RETAIN RECORD')
#IF(%CopyKey)
#INSERT(%SaveScrFlds)
#INSERT(%DupField)
#ENDIF
#ENDIF
#!
#!***************************************************************************
#PROCEDURE(MemForm21,'Version 2.1-Style MemForm Procedure'),SCREEN,PULLDOWN
#!
#!┌──────────────────────────┤Procedure Template├──────────┬─────────────────┐
#!│ MemForm21 │Version: 3007.105│
#!├──────────────────────────────┤Description├─────────────┴─────────────────┤
#!│ The MemForm21 Template generates a Clarion Professional Developer 2.1 │
#!│ type MEMForm procedure (A FORM without a file associated with it). │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!│3007.105 Completed support for PullDowns │
#!│ Added conditional generation of GET(%Primary,0), based on the │
#!│ existance of %Primary │
#!│ Changed ESC key handling to be identical with Form21 handling │
#!│ Moved CASE KEYCODE() handing to Form21KeyHandling GROUP │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#PROTOTYPE('')
#PROMPT('Next Procedure ',PROCEDURE),%NextProcedure
#INSERT(%StandardHeader)
%Procedure PROCEDURE
%LocalData
SelectedField SHORT
NoMoreFields BYTE(0) !No more fields flag
%ScreenStructure
#IF(%PullDown)
%PulldownStructure
SAV::PullDownOpened BYTE(0)
#ENDIF
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#SET(%OkExists,%Null)
#SET(%CancelExists,%Null)
#FIX(%ScreenField,'?Ok')
#IF(%ScreenField)
#SET(%OkExists,'1')
#ENDIF
#FIX(%ScreenField,'?Cancel')
#IF(%ScreenField)
#SET(%CancelExists,'1')
#ENDIF
#SET(%FirstField,%Null)
#FOR(%ScreenField)
#IF(%ScreenFieldSkip <> 'Y' AND %FirstField= %Null)
#SET(%FirstField,%ScreenField)
#ENDIF
#IF(%ScreenFieldSkip <> 'Y')
#SET(%LastField,%ScreenField)
#ENDIF
#ENDFOR
#IF(%FirstField = %Null AND %CancelExists = %NULL)
#SET(%ErrorMessage,'Form21 Must Have Cancel Button If All Fields Are SKIP')
#ERROR(%ErrorMessage)
#ENDIF
#SET(%TableForm,'1')
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'SETUP')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#IF(%SecondaryExist) #<!IF schema has a Secondary
DO SecondaryLookups !Read any lookup fields
#ENDIF
#IF(%PullDownStructure)
OPEN(%PullDown)
SAV::PullDownOpened = True
#EMBED('Setup Pulldown') #! Embedded Source Code
#ENDIF
OPEN(Screen) !Open the FORM screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
LOOP !Begin Main process loop
#IF(%SecondaryExist) #<!IF File schema has Secondary
#INSERT(%SecondaryChanged)
#ENDIF
#IF(%LoopFormulasExist = 'TRUE') #<!Are there Formula fields?
#SET(%GenerateFormulasOn,'TRUE')
DO FormulaFields !Calculate Formula fields
#ENDIF
#EMBED('Computed Fields')
DISPLAY
SelectedField = SELECTED()
IF FIELD() = %LastField AND SelectedField = %LastField
SelectedField = NoMoreFields !Enter On Last Field
END
CASE SelectedField
#INSERT(%ScreenSetupRoutines)
OF NoMoreFields !User pressed Enter or OK
#EMBED('Before Next Procedure')
%NextProcedure
#EMBED('After Next Procedure')
DO ProcedureReturn !Break from main Loop
END !End CASE Selected()
ALERT(EscKey)
#IF(%CancelExists = %Null)
ALERT(CtrlEsc)
#ENDIF
#IF(%OKExists = %Null)
ALERT(CtrlEnter)
#ENDIF
ACCEPT !Enable screen entry
#INSERT(%Form21KeyHandling)
#IF(%CancelExists = %Null)
IF KEYCODE() = CtrlEsc OR (KEYCODE() = EscKey AND FIELD() = %FirstField)
DO ProcedureReturn #<!Break from main LOOP
END
#ENDIF
CASE FIELD() !Process fields
#FOR(%ScreenField)
#IF(%ScreenFieldUse = '?Ok')
OF ?Ok !On the OK button
#EMBED('OK Button Press')
#IF(%ScreenFieldEdit <> %NULL)
%ScreenFieldEdit #<!Field Edit procedure
#ENDIF
SELECT(1) !Start with the first field
SELECT !and cycle non-stop
CYCLE !restart main process loop
#ELSIF(%ScreenFieldUse = '?Cancel')
OF ?Cancel !On Cancel button
#IF(%ScreenFieldEdit <> %NULL)
%ScreenFieldEdit #<!Field edit procedure
#ENDIF
#IF(%Primary)
GET(%Primary,0) #<!signal Browse to re-read
#ENDIF
DO ProcedureReturn !Break from main LOOP
#ELSIF(%ScreenField = %LastField)
OF %LastField
#IF(%ScreenFieldEdit <> %NULL)
%ScreenFieldEdit #<!Field edit procedure
#ENDIF
CYCLE !restart main process loop
#ELSE
#INSERT(%ScreenEditRoutines) #<! Completed %ScreenField
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD
END !END MAIN PROCESS LOOP
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'RETURN')
#INSERT(%GenerateFormula) #<!Return Class formula
#ENDIF
#ENDFOR
DO ProcedureReturn
!─────────────────────────────────────────────────────────────────────────────
ProcedureReturn ROUTINE
#IF(%Pulldown) #! If a Pulldown exists
IF SAV::PullDownOpened #<! IF the pulldown opened
CLOSE(%Pulldown) #<! Close the Pulldown
END #<! END (IF the pulldown...)
#ENDIF #! END (IF a PullDown...)
DO EndOfProcedureEmbed
RETURN
!─────────────────────────────────────────────────────────────────────────────
EndOfProcedureEmbed ROUTINE
#EMBED('End of Procedure')
#EMBED('Custom Routines')
#INSERT(%InitFields)
#INSERT(%GenFormulas)
#IF(%SecondaryExist)
#INSERT(%SecondaryLookups)
#ENDIF
#!***************************************************************************
#!
#PROCEDURE(Menu21,'Version 2.1-Style Menu Procedure'),SCREEN,PULLDOWN
#!
#!┌──────────────────────────┤Procedure Template├──────────┬─────────────────┐
#!│ Menu21 │Version: 3007.105│
#!├──────────────────────────────┤Description├─────────────┴─────────────────┤
#!│ The Menu21 Template generates a Clarion Professional Developer 2.1 type │
#!│ Menu procedure. │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!│3007.105 Completed support for PullDowns │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
#PROTOTYPE('')
#INSERT(%StandardHeader)
%Procedure PROCEDURE
LOC::FromField BYTE
LOC::NextField BYTE
%LocalData
%ScreenStructure
#IF(%PullDown)
%PulldownStructure
SAV::PullDownOpened BYTE(0)
#ENDIF
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#SET(%FirstField,%Null)
#FOR(%ScreenField)
#IF(%ScreenFieldSkip <> 'Y' AND %FirstField= %Null)
#SET(%FirstField,%ScreenField)
#ENDIF
#IF(%ScreenFieldSkip <> 'Y')
#SET(%LastField,%ScreenField)
#ENDIF
#ENDFOR
#SET(%TableForm,'1')
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'SETUP')
#INSERT(%GenerateFormula)
#ENDIF
#ENDFOR
#IF(%SecondaryExist) #<!IF schema has a Secondary
DO SecondaryLookups !Read any lookup fields
#ENDIF
#IF(%PullDownStructure)
OPEN(%PullDown)
SAV::PullDownOpened = True
#EMBED('Setup Pulldown') #! Embedded Source Code
#ENDIF
OPEN(Screen) !Open the FORM screen
#EMBED('Setup Screen')
DISPLAY !Display screen fields
LOOP !Begin Main process loop
#IF(%SecondaryExist) #!IF File schema has Secondary
#INSERT(%SecondaryChanged)
#ENDIF
#IF(%LoopFormulasExist = 'TRUE') #!Are there Formula fields?
#SET(%GenerateFormulasOn,'TRUE')
DO FormulaFields !Calculate Formula fields
#ENDIF
#EMBED('Computed Fields')
DISPLAY
CASE SELECTED()
#INSERT(%ScreenSetupRoutines)
END !End CASE Selected()
ALERT
ALERT(EscKey)
ALERT(CtrlEsc)
ACCEPT !Enable screen entry
CASE KEYCODE()
OF CtrlEsc !User press CtrlEsc key
Do ProcedureReturn
OF EscKey !User pressed Escape key
IF SELECTED() = %FirstField #<!If Escape On first field
DO ProcedureReturn ! BREAK from main loop
ELSIF FIELD() = 0 !If Escape On Button
LOC::FromField = SELECTED() !Save Current Button Number
Select(1) !Select First Field
SELECT() !Select NonStop mode
CYCLE !Cycle to Accept
ELSE
SELECT(?-1) !Select Previous Field
CYCLE !Cycle to Accept
END !Field was not Cancel button
#FOR(%HotKey)
OF %HotKey #<!User defined HotKey
%HotKeyProc #<!HotKey Procedure
#ENDFOR
END !End CASE Keycode
!If looking for prior field
IF LOC::FromField !from button
IF FIELD() !If entry field
LOC::NextField = FIELD() !Save as previous entry field
END
IF SELECTED() = LOC::FromField !If next field is original button
IF LOC::NextField !If found previous entry
SELECT(LOC::NextField) !Set to previous entry
LOC::NextField = 0 !Clear previous entry field number
LOC::FromField = 0 !Clear button field number
CYCLE !Cycle to top of loop
ELSE
DO ProcedureReturn !No Previous entry, Exit
END
END !looking for prior field
CYCLE !Cycle to top of loop
END
CASE FIELD() !Process fields
#FOR(%ScreenField)
#INSERT(%ScreenEditRoutines) #<! Completed %ScreenField
#ENDFOR
#INSERT(%PulldownEditRoutines)
END !End CASE FIELD
END !END MAIN PROCESS LOOP
ALERT
#FOR(%Formula)
#IF(UPPER(%FormulaClass) = 'RETURN')
#INSERT(%GenerateFormula) #<!Return Class formula
#ENDIF
#ENDFOR
DO ProcedureReturn
!─────────────────────────────────────────────────────────────────────────────
ProcedureReturn ROUTINE
#IF(%Pulldown) #! If a Pulldown exists
IF SAV::PullDownOpened #<! IF the pulldown opened
CLOSE(%Pulldown) #<! Close the Pulldown
END #<! END (IF the pulldown...)
#ENDIF #! END (IF a PullDown...)
DO EndOfProcedureEmbed
RETURN
!─────────────────────────────────────────────────────────────────────────────
EndOfProcedureEmbed ROUTINE
#EMBED('End of Procedure')
#EMBED('Custom Routines')
#INSERT(%InitFields)
#INSERT(%GenFormulas)
#IF(%SecondaryExist)
#INSERT(%SecondaryLookups)
#ENDIF
#!------------------------------------------------------------------------------
#!
#! Begin Repeat
#!
#! Same as BeginBrowse to work with the Table21 template.
#!
#!------------------------------------------------------------------------------
#GROUP(%BeginRepeat)
#IF(%Locator) #!Conditionally initialize
#IF(%IncrementalLocator)
#IF(%HotBar OR %First) #! the browse session manager
BeginRepeat(?Point,MaxRows,?%Locator,1,1)
#ELSE
BeginRepeat(?Point,MaxRows,?%Locator,,1)
#ENDIF
#ELSE
#IF(%HotBar OR %First) #! the browse session manager
BeginRepeat(?Point,MaxRows,?%Locator,1)
#ELSE
BeginRepeat(?Point,MaxRows,?%Locator)
#ENDIF
#ENDIF
#ELSE
#IF(%HotBar OR %First)
BeginRepeat(?Point,MaxRows,,1) #<!Begin a browse session
#ELSE
BeginRepeat(?Point,MaxRows) #<!Begin a browse session
#ENDIF
#ENDIF
#!------------------------------------------------------------------------------
#!
#! Repeat Error Check
#!
#!------------------------------------------------------------------------------
#GROUP(%RepeatErrorCheck)
#!
#IF(%Primary = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: No file has been chosen for this procedure.'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' A file must be selected for this procedure.')
#ERROR(%ErrorMessage)
#ENDIF
#IF(%PrimaryKey = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: No Access Key has been chosen for this procedure.'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' An Access Key must be identified on the File Schematic.')
#ERROR(%ErrorMessage)
#ENDIF
#IF(%KeyRangeField)
#IF(%KeyNoCase) #! Key is not case sensitive
#IF(UPPER(%KeyRangeField) = UPPER(%RangeValue))
#SET(%ErrorMessage, (%Procedure & ' ERROR: Range Limit Field and Range Value fields must'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' be separate fields.')
#ERROR(%ErrorMessage)
#ENDIF
#ELSE
#IF(%KeyRangeField = %RangeValue)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Range Limit Field and Range Value fields must'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' be separate fields.')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#ENDIF
#IF(%First)
#SET(%FirstHotEquate, ('?' & %First))
#FIX(%ScreenField,%FirstHotEquate)
#IF(%ScreenField <> %FirstHotEquate)
#SET(%ErrorMessage, (%Procedure & ' ERROR: the First Hot field must be a display'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' field on the SCREEN. ')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#IF(%Last)
#SET(%LastHotEquate, ('?' & %Last))
#FIX(%ScreenField,%LastHotEquate)
#IF(%ScreenField <> %LastHotEquate)
#SET(%ErrorMessage, (%Procedure & ' ERROR: the Last Hot field must be a display'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' field on the SCREEN. ')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#FIX(%File,%Primary)
#IF(%DisplayKey)
#FIX(%Key,%DisplayKey)
#ELSE
#FIX(%Key,%PrimaryKey)
#ENDIF
#FIX(%Key,%PrimaryKey)
#IF(%KeyRangeField)
#SET(%FieldFound,%Null)
#FOR(%KeyField)
#IF(%KeyNoCase)
#IF(UPPER(%KeyField) = UPPER(%KeyRangeField))
#SET(%FieldFound,'Yes')
#BREAK
#ENDIF
#ELSE
#IF(%KeyField = %KeyRangeField)
#SET(%FieldFound,'Yes')
#BREAK
#ENDIF
#ENDIF
#ENDFOR
#IF(%FieldFound = %Null)
#SET(%ErrorMessage, (%Procedure & ' ERROR: Key Range Limit Field must be a component of the'))
#ERROR(%ErrorMessage)
#SET(%ErrorMessage, ' File Access Key')
#ERROR(%ErrorMessage)
#ENDIF
#ENDIF
#!***************************************************************************
#GROUP(%Form21KeyHandling)
#!
#!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
#!│ Form21KeyHandling │Version: 3007.105│
#!├──────────────────────────────┤Description├─────────────┴─────────────────┤
#!│Purpose: Handle Form21 (and MemForm21) CASE KEYCODE() generation │
#!│Called From: Form21 PROCEDURE │
#!│ MEMForm21 PROCEDURE │
#!│Assumptions: None │
#!│Inserts: None │
#!│Symbols Set: None │
#!│Notes: None │
#!├───────────────────────────────┤Comments├─────────────────────────────────┤
#!│Version Comments │
#!│──────── ────────────────────────────────────────────────────────────────│
#!│3007.000 Release of CDD3 version 3007 templates │
#!│3007.105 Added to CPD21.TPX │
#!└──────────────────────────────────────────────────────────────────────────┘
#!
CASE KEYCODE()
OF CtrlEsc #<! User Wants Out
#FOR(%HotKey)
#IF(UPPER(%HotKey) = 'CTRLESC')
%HotKeyProc #<! HotKey Procedure
#BREAK
#ENDIF
#ENDFOR
#IF(%CancelExists)
IF FIELD() <> ?Cancel #<! If user pressed Escape
SELECT(?Cancel) #<! Select Cancel button
PRESS(EnterKey) #<! Process Cancel button code
CYCLE #<! Cycle to Accept
END #<! Field was not Cancel button
#ENDIF
OF CtrlEnter #<! User Wants to Save Screen
#FOR(%HotKey)
#IF(UPPER(%HotKey) = 'CTRLENTER')
%HotKeyProc #<! HotKey Procedure
#BREAK
#ENDIF
#ENDFOR
SELECT(1) #<! Start with the first field
SELECT #<! and cycle non-stop
CYCLE #<! restart main process loop
OF EscKey #<! User pressed Escape key
#IF(%CancelExists)
IF FIELD() = %FirstField #<! If Escape On first field
SELECT(?Cancel) #<! Select Cancel button
PRESS(EnterKey) #<! Process Cancel button code
CYCLE #<! Cycle to Accept
#ELSE
IF FIELD() = %FirstField #<! If Escape On first field
SETKEYCODE(CtrlEsc) #<! Select Cancel button
#ENDIF
ELSIF FIELD() > 0
SELECT(?-1) #<! Select Previous Field
CYCLE #<! Cycle to Accept
END #<! Field was not Cancel button
#IF(%HotKeysExist)
#FOR(%HotKey)
OF %HotKey #<! User defined HotKey
%HotKeyProc #<! HotKey Procedure
#ENDFOR
#ENDIF
END #<! End CASE Keycode
#!***************************************************************************